/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package action;

import chainOfResponsability.Funcionario;
import chainOfResponsability.FuncionarioCoordenador;
import chainOfResponsability.FuncionarioProfessor;
import chainOfResponsability.FuncionarioSecretaria;
import controller.Action;
import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Rodolfo
 */
public class PermissaoAction extends Action {

    @Override
    public void prepararOperacao(HttpServletRequest request, HttpServletResponse response) throws ServletException {

        try {

            Funcionario secretaria = new FuncionarioSecretaria(null);
            Funcionario coordenador = new FuncionarioCoordenador(secretaria);
            Funcionario professor = new FuncionarioProfessor(coordenador);

            String relatorio = request.getParameter("relatorio");

            String cargo = professor.exibirRelatorio(relatorio);
            request.setAttribute("cargo", cargo);
            request.setAttribute("relatorio", relatorio);

            RequestDispatcher view = request.getRequestDispatcher("/permissaoRelatorio.jsp");
            view.forward(request, response);
        } catch (ServletException e) {
            throw e;
        } catch (IOException e) {
            throw new ServletException(e);
        }
    }

    @Override
    public void confirmarOperacao(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

}
